﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sociedad.BL;
using Sociedad.DAL;

public partial class SOA_General_ConsultarEntidad : System.Web.UI.Page
{
    EntidadBL blEnt = new EntidadBL();

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                Inicializar();
            }
            else
            {
                lblMsj.Visible = false;
            }
        }
        catch (Exception ex)
        {
            lblMsj.Text = "Se produjo un error al intentar cargar los datos, volver a intentar.";
            lblMsj.ForeColor = System.Drawing.Color.Red;
            lblMsj.Visible = true; 
        }
    }

    private void Inicializar()
    {

    }

    protected void imbCerrar_Click(object sender, ImageClickEventArgs e)
    {
        string cmd = "window.close()";
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Cerrar", cmd, true);
    }

    private void CargarGrilla()
    {
        grvLista.DataSource = blEnt.Buscar_Entidades(txtEntidad.Text);
        grvLista.DataBind();
    }

    protected void imbBuscar_Click(object sender, ImageClickEventArgs e)
    {
        CargarGrilla();
    }
    protected void grvLista_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvLista.PageIndex = e.NewPageIndex;
        CargarGrilla();
    }
}